package com.nbsaas.boot.finance.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.util.Date;
import java.util.List;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "凭证", model = "凭证")
@Entity
@Table(name = "bs_voucher")
@Comment("凭证表")
public class Voucher extends AbstractEntity {

    @Comment("凭证号")
    @FormField(title = "凭证号", sortNum = "1", grid = true, required = true)
    @Column(length = 50, nullable = false, unique = true)
    private String voucherNo;

    @Comment("凭证日期")
    @FormField(title = "凭证日期", sortNum = "2", type = InputType.date, grid = true)
    private Date voucherDate;

    @Comment("会计期间")
    @FormField(title = "会计期间", sortNum = "3", grid = true)
    @Column(length = 20)
    private String period;

    @Comment("状态")
    @FormField(title = "状态", sortNum = "4", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "5", type = InputType.textarea)
    private String remark;

    @OneToMany(mappedBy = "voucher", cascade = CascadeType.ALL, orphanRemoval = true)
    private List<VoucherEntry> entries;
} 